<!DOCTYPE html>
<!--[if lt IE 7 ]><html lang="en" class="ie6 ielt7 ielt8 ielt9"><![endif]--><!--[if IE 7 ]><html lang="en" class="ie7 ielt8 ielt9"><![endif]--><!--[if IE 8 ]><html lang="en" class="ie8 ielt9"><![endif]--><!--[if IE 9 ]><html lang="en" class="ie9"> <![endif]--><!--[if (gt IE 9)|!(IE)]><!--> 
<html lang="en"><!--<![endif]--> 
	<head>
		<meta charset="utf-8">
		<title>成员</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
		<link href="css/site.css" rel="stylesheet">
		<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
	</head>
	<body>
		<div class="container">
			<div class="navbar">
				<div class="navbar-inner">
					<div class="container">
						<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="#">Akira</a>
						<div class="nav-collapse">
							<ul class="nav">
								<li>
									<a href="role-table.html">角色管理</a>
								</li>
								<li>
									<a href="user-table.html">成员管理</a>
								</li>
								<li>
									<a href="city-tree.html">城市树</a>
								</li>
							</ul>
							<ul class="nav pull-right">
								<li>
									<a href="">@username</a>
								</li>
								<li>
									<a href="login.html">Logout</a>
								</li>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<div class="row">
				<div class="span3">
					<div class="well" style="padding: 8px 0;">
						<ul class="nav nav-list">
							<li>
								<a href="role-table.html"><i class="icon-list-alt"></i> 角色管理</a>
							</li>
							<li class="active">
								<a href="user-table.html"><i class="icon-white icon-list-alt"></i> 成员管理</a>
							</li>
							<li>
								<a href="city-tree.html"><i class="icon-list-alt"></i> 城市树</a>
							</li>
						</ul>
					</div>
				</div>
				<div class="span9">
					<h1>成员管理</h1>
					<a id="addUserBtn" class="btn btn-primary" href="" style="margin-bottom:10px">增加成员</a>
					<table id="bsTable" class="table-bordered table-striped"></table>
				</div>
			</div>

		</div>
		<script src="js/jquery.min.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/bootbox.min.js"></script>
		<script src="js/bootstrap-table.js"></script>
		<script src="js/bootstrap-table-zh-CN.js"></script>
		<script src="js/site.js"></script>
			
		<script>
			var urls = {
				tableData: 'a',
				add: '',
				update: '',
				remove: ''
			}
			$(function() {

				//设置增加成员链接
				$('#addUserBtn').attr('href', urls.add);

				$('#bsTable').bootstrapTable({
					url: urls.tableData,
					data: [{
						userId: 1212,
						userName: 'ffds',
						userPwd: 12,
						userEmail: 0,
						userMobile: 0,
						userOpenId: 0,
						userRegisterTime: 0,
						userRegisterIp: 0,
						userLastLoginTime: 0,
						userLastLoginIp: 0,
						userStatus: 0
					}],
					pagination: false,
					columns: [{
						field: 'userId',
						title: '成员ID'
					}, {
						field: 'userName',
						title: '成员名称'
					}, {
						field: 'userPwd',
						title: '密码'
					}, {
						field: 'userEmail',
						title: '邮箱'
					}, {
						field: 'userMobile',
						title: '手机'
					}, {
						field: 'userOpenId',
						title: 'open id'
					}, {
						field: 'userRegisterTime',
						title: '注册时间'
					}, {
						field: 'userRegisterIp',
						title: '注册IP'
					}, {
						field: 'userLastLoginTime',
						title: '上次登陆时间'
					},  {
						field: 'userLastLoginIp',
						title: '上次登陆IP'
					},  {
						field: 'userStatus',
						title: '成员状态'
					}, {
						field: 'userId',
						title: '操作',
						formatter: function (id) {
							//TODO 修改也要传入id
							return '<a class="btn btn-primary" href="' + urls.update + '">修改</a>'
							+ ' <button class="btn btn-danger" onclick="remove(' + id + ')">删除</button>'
						}
					}],
				});
			});

			function remove(userId) {
				bootbox.confirm('确认删除此成员？', function(result) {
					if(!result) {
						return;
					}
					$.ajax({
						url: urls.remove,
						data: {
							userId: userId
						},
						success: function () {
							$('#bsTable').bootstrapTable('refresh');
						}
					});
				});
			}
		</script>
		
	</body>
</html>
